<?php
namespace app\api\controller;

use think\Db;
class News
{

    /**
     * @api {get} api\news\news 获取新闻
     * @apiGroup Group
     * @apiDescription 获取新闻
     * @apiSuccess {String} id 新闻id
     * @apiSuccess {String} title 新闻标题
     * @apiSuccess {String} description 新闻简述
     * @apiSuccess {String} news_cate_id 新闻分类id
     * @apiSuccess {String} thumb 新闻图片
     * @apiSuccess {text} content 新闻内容
     * @apiSuccessExample 数据:
     * {
    "code": 200,
    "mag": "请求成功",
    "data": [
    {
    "id": 4,
    "title": "aa3",
    "description": "aa",
    "news_cate_id": 1,
    "thumb": 22,
    "content": "aa"
    }
    ]
    }
     */
    public function news(){
        $data=Db::name('news')
            ->field('id,title,description,news_cate_id,thumb,content')
            ->select();
        foreach ($data as $k=>$v){
            $data[$k]['content']= strip_tags(str_replace('&nbsp;','',$v['content']));
        }
        if($data){
            return json(['code'=>200,'mag'=>"请求成功",'data'=>$data]);
        }else{
            return json(['code'=>0,'mag'=>"请求失败"]);
        }
    }
    
}